<template>
  <div class="hello">
    <el-card>
      <el-table :data="myData11" :height="tableHeight" stripe>
        <el-table-column prop="addTime" label="时间" width="100px">
          <template slot-scope="scope">
            {{ fmtDate(scope.row.addTime) }}</template
          >
        </el-table-column>
        <el-table-column prop="authorId" label="作者ID" width="100px">
        </el-table-column>
        <el-table-column prop="factorId" label="因子id" width="100px">
        </el-table-column>
        <el-table-column prop="factorName" label="因子名称" width="200px">
        </el-table-column>
        <el-table-column prop="factorType" label="因子类型" width="100px">
        </el-table-column>
        <el-table-column prop="feeId" label="feeId" width="100px">
        </el-table-column>
        <el-table-column prop="lastUpdateDt" label="最新时间" width="200px">
          <template slot-scope="scope">
            {{ fmtDate(scope.row.lastUpdateDt) }}</template
          >
        </el-table-column>
        <!-- <el-table-column
              prop="linkId"
              label="linkId"
              width="200px"
            >
          </el-table-column> -->
        <el-table-column prop="note" label="因子说明" width="200px">
        </el-table-column>
        <el-table-column prop="tableName" label="tableName" width="200px">
        </el-table-column>
        <el-table-column prop="updateTime" label="更新时间" width="200px">
          <template slot-scope="scope">
            {{ fmtDate(scope.row.updateTime) }}</template
          >
        </el-table-column>
        <el-table-column label="查看详情" width="200px">
          <router-link to="/factors" style="text-decoration: none;"
            ><span>查看详情</span></router-link
          >
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
<script>
export default {
  data() {
    return {
      myData11: [],
      myData1: {}
    }
  },
  mounted: function() {
    this.show1()
  },
  methods: {
    show1() {
      this.$axios
        .get(
          'http://121.196.123.12:8095/lmdfactors/lmd_factors_list?factor_id=&factor_name=&factor_type=&fee_id='
        )
        .then(res => {
          console.log(res.data)
          this.myData1 = res.data
          const myData11 = []
          for (let i = 0; i < res.data.data.factors.length; i++) {
            myData11.push(res.data.data.factors[i])
          }
          this.myData11 = myData11
        })
    },
    fmtDate(obj) {
      obj = typeof obj === 'number' ? obj : Number(obj)
      var date = new Date(obj)
      var y = 1900 + date.getYear()
      var m = '0' + (date.getMonth() + 1)
      var d = '0' + date.getDate()
      return (
        y +
        '-' +
        m.substring(m.length - 2, m.length) +
        '-' +
        d.substring(d.length - 2, d.length)
      )
    }
  },
  created() {
    // 3. 动态计算表格高度
    const windowHeight =
      document.documentElement.clientHeight || document.body.clientHeight
    // 此处减去100即为当前屏幕内除了表格高度以外其它内容的总高度，
    this.tableHeight = windowHeight - 150
  }
}
</script>

<style scoped></style>
